package com.itqf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itqf.bean.DtsStorage;
import com.itqf.dto.DtsSearchDto;
import com.itqf.mapper.DtsStorageMapper;
import com.itqf.service.DtsStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * projectName: sm_project
 *
 * @author: 赵伟风
 * time: 2021/7/16 17:08
 * description:
 */
@Service
public class DtsStorageServiceImpl implements DtsStorageService {

    @Autowired
    private DtsStorageMapper dtsStorageMapper;

    @Override
    public void save(DtsStorage dtsStorage) {

       dtsStorageMapper.insert(dtsStorage);

    }

    @Override
    public Map query(DtsSearchDto dto) {

        PageHelper.startPage(dto.getPage(), dto.getLimit());

        List<DtsStorage> dtsStorages = dtsStorageMapper.queryList(dto);

        PageInfo<DtsStorage> pageInfo = new PageInfo<>(dtsStorages);

        Map data = new HashMap();
        data.put("total", pageInfo.getTotal());
        data.put("items", pageInfo.getList());

        return data;
    }
}
